#ifndef SPI_FLASH_EN25F80_H
#define SPI_FLASH_EN25F80_H

#include "common_func.h"
#include "spi.h"
#include <stdio.h> 

#ifdef __cplusplus
 extern "C" {
#endif

#define RFEMPTY 1
#define SPIF_PAGE_SIZE  256

#define  CS_L    spi_cs_down()
#define  CS_H    spi_cs_up()

#define  SEND_CMD(x)    spi_wr_data8(x)

#define  GET_DATA(x)    (x) = spi_rd_data8();

#define  SEND_DATA(x)   SEND_CMD(x)

#define min(a,b) ((a<b)?a:b)

int spi_flash_read_sr(void);
int spi_flash_write_sr(char sr);
int spi_flash_wait_sr(void);
int spi_flash_set_wren(void);
void spi_flash_read_id(void);
int spi_flash_erase_all(void);
int spi_flash_erase_area(unsigned int saddr,unsigned int eaddr,unsigned sectorsize);
void spi_flash_write_byte(unsigned int addr,unsigned char data);
void spi_flash_write_page(unsigned int addr,unsigned char *buf,unsigned int num);
int spi_flash_write_area(int flashaddr,char *buffer,int size);
uint8_t spi_flash_read_byte(int flashaddr);
int spi_flash_read_area(int flashaddr,char *buffer,int size);
int spi_flash_erase_write(unsigned int ramaddr, unsigned int flashaddr, unsigned int size);

#ifdef __cplusplus
}
#endif
#endif 
